package org.learm.base.enums;

/**
 * 枚举 
 * 	用枚举的好处:使代码可读性更强
 * 	使用地点:switch 语句
 * 	使用方式:类似 class 
 * 
 *  @author 5king
 *
 */
public enum ColorEnumTest {
	RED("红色", 1),YELLOW("黄色",2);
	
	private String depictName;
	private Integer index;
	private ColorEnumTest(String depictName, Integer index) {
		this.depictName = depictName;
		this.index = index;
	}
	
	public void setDepictName(String depictName) {
		this.depictName = depictName;
	}
	public void setIndex(Integer index) {
		this.index = index;
	}
	public static String getDepictName(Integer index) {
		for(ColorEnumTest color : ColorEnumTest.values()) {
			if(color.getIndex() == index) {
				return color.depictName;
			}
		}
		return null;
	}
	public String getName() {
		return depictName;
	}
	public Integer getIndex() {
		return index;
	}

	public String toString() {
		return this.index + " _ " + this.depictName;
	}
	
}	
